home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / os2 / e33el2.zip / emacs / 19.33 / lisp / inf-lisp.el < prev    next >
Lisp/Scheme  |  1996-05-23  |  27KB  |  643 lines

  1. ;;; inf-lisp.el --- an inferior-lisp mode
  2.  
  3. ;; Copyright (C) 1988, 1993, 1994 Free Software Foundation, Inc.
  4.  
  5. ;; Author: Olin Shivers <shivers@cs.cmu.edu>
  6. ;; Keywords: processes, lisp
  7.  
  8. ;; This file is part of GNU Emacs.
  9.  
  10. ;; GNU Emacs is free software; you can redistribute it and/or modify
  11. ;; it under the terms of the GNU General Public License as published by
  12. ;; the Free Software Foundation; either version 2, or (at your option)
  13. ;; any later version.
  14.  
  15. ;; GNU Emacs is distributed in the hope that it will be useful,
  16. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18. ;; GNU General Public License for more details.
  19.  
  20. ;; You should have received a copy of the GNU General Public License
  21. ;; along with GNU Emacs; see the file COPYING.  If not, write to the
  22. ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  23. ;; Boston, MA 02111-1307, USA.
  24.  
  25. ;;; Commentary:
  26.  
  27. ;; Hacked from tea.el by Olin Shivers (shivers@cs.cmu.edu). 8/88
  28.  
  29. ;; This file defines a a lisp-in-a-buffer package (inferior-lisp
  30. ;; mode) built on top of comint mode.  This version is more
  31. ;; featureful, robust, and uniform than the Emacs 18 version.  The
  32. ;; key bindings are also more compatible with the bindings of Hemlock
  33. ;; and Zwei (the Lisp Machine emacs).
  34.  
  35. ;; Since this mode is built on top of the general command-interpreter-in-
  36. ;; a-buffer mode (comint mode), it shares a common base functionality, 
  37. ;; and a common set of bindings, with all modes derived from comint mode.
  38. ;; This makes these modes easier to use.
  39.  
  40. ;; For documentation on the functionality provided by comint mode, and
  41. ;; the hooks available for customising it, see the file comint.el.
  42. ;; For further information on inferior-lisp mode, see the comments below.
  43.  
  44. ;; Needs fixin:
  45. ;; The load-file/compile-file default mechanism could be smarter -- it
  46. ;; doesn't know about the relationship between filename extensions and
  47. ;; whether the file is source or executable. If you compile foo.lisp
  48. ;; with compile-file, then the next load-file should use foo.bin for
  49. ;; the default, not foo.lisp. This is tricky to do right, particularly
  50. ;; because the extension for executable files varies so much (.o, .bin,
  51. ;; .lbin, .mo, .vo, .ao, ...).
  52. ;;
  53. ;; It would be nice if inferior-lisp (and inferior scheme, T, ...) modes
  54. ;; had a verbose minor mode wherein sending or compiling defuns, etc.
  55. ;; would be reflected in the transcript with suitable comments, e.g.
  56. ;; ";;; redefining fact". Several ways to do this. Which is right?
  57. ;;
  58. ;; When sending text from a source file to a subprocess, the process-mark can 
  59. ;; move off the window, so you can lose sight of the process interactions.
  60. ;; Maybe I should ensure the process mark is in the window when I send
  61. ;; text to the process? Switch selectable?
  62.  
  63. ;;; Code:
  64.  
  65. (require 'comint)
  66. (require 'lisp-mode)
  67.  
  68.  
  69. ;;;###autoload
  70. (defvar inferior-lisp-filter-regexp "\\`\\s *\\(:\\(\\w\\|\\s_\\)\\)?\\s *\\'"
  71.   "*What not to save on inferior Lisp's input history.
  72. Input matching this regexp is not saved on the input history in Inferior Lisp
  73. mode.  Default is whitespace followed by 0 or 1 single-letter colon-keyword 
  74. \(as in :a, :c, etc.)")
  75.  
  76. (defvar inferior-lisp-mode-map nil)
  77. (cond ((not inferior-lisp-mode-map)
  78.        (setq inferior-lisp-mode-map
  79.          (copy-keymap comint-mode-map))
  80.        (setq inferior-lisp-mode-map
  81.          (nconc inferior-lisp-mode-map shared-lisp-mode-map))
  82.        (define-key inferior-lisp-mode-map "\C-x\C-e" 'lisp-eval-last-sexp)
  83.        (define-key inferior-lisp-mode-map "\C-c\C-l" 'lisp-load-file)
  84.        (define-key inferior-lisp-mode-map "\C-c\C-k" 'lisp-compile-file)
  85.        (define-key inferior-lisp-mode-map "\C-c\C-a" 'lisp-show-arglist)
  86.        (define-key inferior-lisp-mode-map "\C-c\C-d" 'lisp-describe-sym)
  87.        (define-key inferior-lisp-mode-map "\C-c\C-f"
  88.      'lisp-show-function-documentation)
  89.        (define-key inferior-lisp-mode-map "\C-c\C-v"
  90.      'lisp-show-variable-documentation)))
  91.  
  92. ;;; These commands augment Lisp mode, so you can process Lisp code in
  93. ;;; the source files.
  94. (define-key lisp-mode-map "\M-\C-x"  'lisp-eval-defun)     ; Gnu convention
  95. (define-key lisp-mode-map "\C-x\C-e" 'lisp-eval-last-sexp) ; Gnu convention
  96. (define-key lisp-mode-map "\C-c\C-e" 'lisp-eval-defun)
  97. (define-key lisp-mode-map "\C-c\C-r" 'lisp-eval-region)
  98. (define-key lisp-mode-map "\C-c\C-c" 'lisp-compile-defun)
  99. (define-key lisp-mode-map "\C-c\C-z" 'switch-to-lisp)
  100. (define-key lisp-mode-map "\C-c\C-l" 'lisp-load-file)
  101. (define-key lisp-mode-map "\C-c\C-k" 'lisp-compile-file)  ; "kompile" file
  102. (define-key lisp-mode-map "\C-c\C-a" 'lisp-show-arglist)
  103. (define-key lisp-mode-map "\C-c\C-d" 'lisp-describe-sym)
  104. (define-key lisp-mode-map "\C-c\C-f" 'lisp-show-function-documentation)
  105. (define-key lisp-mode-map "\C-c\C-v" 'lisp-show-variable-documentation)
  106.  
  107.  
  108. ;;; This function exists for backwards compatibility.
  109. ;;; Previous versions of this package bound commands to C-c <letter>
  110. ;;; bindings, which is not allowed by the gnumacs standard.
  111.  
  112. ;;;  "This function binds many inferior-lisp commands to C-c <letter> bindings,
  113. ;;;where they are more accessible. C-c <letter> bindings are reserved for the
  114. ;;;user, so these bindings are non-standard. If you want them, you should
  115. ;;;have this function called by the inferior-lisp-load-hook:
  116. ;;;    (setq inferior-lisp-load-hook '(inferior-lisp-install-letter-bindings))
  117. ;;;You can modify this function to install just the bindings you want."
  118. (defun inferior-lisp-install-letter-bindings ()
  119.   (define-key lisp-mode-map "\C-ce" 'lisp-eval-defun-and-go)
  120.   (define-key lisp-mode-map "\C-cr" 'lisp-eval-region-and-go)
  121.   (define-key lisp-mode-map "\C-cc" 'lisp-compile-defun-and-go)
  122.   (define-key lisp-mode-map "\C-cz" 'switch-to-lisp)
  123.   (define-key lisp-mode-map "\C-cl" 'lisp-load-file)
  124.   (define-key lisp-mode-map "\C-ck" 'lisp-compile-file)
  125.   (define-key lisp-mode-map "\C-ca" 'lisp-show-arglist)
  126.   (define-key lisp-mode-map "\C-cd" 'lisp-describe-sym)
  127.   (define-key lisp-mode-map "\C-cf" 'lisp-show-function-documentation)
  128.   (define-key lisp-mode-map "\C-cv" 'lisp-show-variable-documentation)
  129.   
  130.   (define-key inferior-lisp-mode-map "\C-cl" 'lisp-load-file)
  131.   (define-key inferior-lisp-mode-map "\C-ck" 'lisp-compile-file)
  132.   (define-key inferior-lisp-mode-map "\C-ca" 'lisp-show-arglist)
  133.   (define-key inferior-lisp-mode-map "\C-cd" 'lisp-describe-sym)
  134.   (define-key inferior-lisp-mode-map "\C-cf" 'lisp-show-function-documentation)
  135.   (define-key inferior-lisp-mode-map "\C-cv"
  136.     'lisp-show-variable-documentation))
  137.  
  138.  
  139. ;;;###autoload
  140. (defvar inferior-lisp-program "lisp"
  141.   "*Program name for invoking an inferior Lisp with for Inferior Lisp mode.")
  142.  
  143. ;;;###autoload
  144. (defvar inferior-lisp-load-command "(load \"%s\")\n"
  145.   "*Format-string for building a Lisp expression to load a file.
  146. This format string should use `%s' to substitute a file name
  147. and should result in a Lisp expression that will command the inferior Lisp
  148. to load that file.  The default works acceptably on most Lisps.
  149. The string \"(progn (load \\\"%s\\\" :verbose nil :print t) (values))\\n\"
  150. produces cosmetically superior output for this application,
  151. but it works only in Common Lisp.")
  152.  
  153. ;;;###autoload
  154. (defvar inferior-lisp-prompt "^[^> \n]*>+:? *"
  155.   "Regexp to recognise prompts in the Inferior Lisp mode.
  156. Defaults to \"^[^> \\n]*>+:? *\", which works pretty good for Lucid, kcl,
  157. and franz.  This variable is used to initialize `comint-prompt-regexp' in the 
  158. Inferior Lisp buffer.
  159.  
  160. More precise choices:
  161. Lucid Common Lisp: \"^\\\\(>\\\\|\\\\(->\\\\)+\\\\) *\"
  162. franz: \"^\\\\(->\\\\|<[0-9]*>:\\\\) *\"
  163. kcl: \"^>+ *\"
  164.  
  165. This is a fine thing to set in your .emacs file.")
  166.  
  167. (defvar inferior-lisp-buffer nil "*The current inferior-lisp process buffer.
  168.  
  169. MULTIPLE PROCESS SUPPORT
  170. ===========================================================================
  171. To run multiple Lisp processes, you start the first up
  172. with \\[inferior-lisp].  It will be in a buffer named `*inferior-lisp*'.
  173. Rename this buffer with \\[rename-buffer].  You